// custom-tab-bar/index.js
Component({
  data: {
    active: 0,
    list: [
      [{
          pagePath: "/pages/index/index",
          text: "首页",
          icon: "首页",
        },
        {
          pagePath: "/pages/message/index",
          text: "消息",
          icon: "消息中心",
        },
        {
          pagePath: "/pages/hospital/index",
          text: "医院主页",
          icon: "医院主页",
        },

        {
          pagePath: "/pages/mainLogs/logs",
          text: "个人中心",
          icon: "个人中心",
        },
        /*  {
          pagePath: "/pages/mainLogs/index",
          text: "个人中心",
          icon: "user",
        }, */
      ],
      [{
          pagePath: "/pagesDoctor/doctorIndex/index",
          text: "接诊",
          icon: "消息中心",
        },
        {
          pagePath: "/pagesDoctor/messagePacket/index",
          text: "患者",
          icon: "多人",
        },
        {
          pagePath: "/pagesDoctor/doctorMessage/index",
          text: "我的",
          icon: "个人中心",
        },
      ],
      [{
          pagePath: "/pagesDoctor/doctorIndex/index",
          text: "处方审核",
          icon: "消息中心",
        },
        {
          pagePath: "/pagesDoctor/doctorMessage/index",
          text: "我的",
          icon: "个人中心",
        },
      ],
    ]
  },

  methods: {
    onChange(e) {
      this.setData({
        active: e.detail
      });
      wx.switchTab({
        url: this.data.selectList[e.detail].pagePath
      });

    },
    init() {
      if (wx.getStorageSync('loginType') == "doctor") {
        this.setData({
          selectList: this.data.list[1]
        })
      } else {
        this.setData({
          selectList: this.data.list[0]
        })
      }
      const page = getCurrentPages().pop();
      this.setData({
        active: this.data.selectList.findIndex(item => item.pagePath === `/${page.route}`)
      });
    },
  }
})